package com.imageim.yimirror.common.util;

import com.imageim.yimirror.base.BaseApplication;
import com.imageim.yimirror.base.Constants;

/**
 * Created by Yuaihen on 2017/12/7.
 */

public class UserUtil {

    //设置Token
    public static void setToken(String value) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.TOKEN, value);
    }

    public static String getToken() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.TOKEN);
    }

    //设置用户Id
    public static void setUserId(String userId) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.USER_ID, userId);
    }

    public static String getUserId() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.USER_ID);
    }

    //设置用户风格
    public static void setStyleId(int value) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.STYLE_ID, value);
    }

    public static int getStyleId() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.STYLE_ID, -1);
    }

    //设置新老用户标签 (flag=1新用户，flag=2老用户)
    public static void setUserFlag(int value) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.USER_FLAG, value);
    }

    public static int getUserFlag() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.USER_FLAG, -1);
    }

    public static void setUseNo(String useNo) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.USE_NO, useNo);
    }

    public static String getUseNo() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.USE_NO);
    }


    public static void setQrCodeUrl(String qrcodePath) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.QR_CODE_URL, qrcodePath);
    }

    public static String getQrCodeUrl() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.QR_CODE_URL);
    }

    public static void setBeanByGson(String key, Object obj) {
        CacheUtils.setBean(BaseApplication.getContext(), key, obj);
    }

    public static <T> T getBeanByGson(String key, Class<T> clazz) {
        return CacheUtils.getBeanByGson(BaseApplication.getContext(), key, clazz);
    }


    public static void setImageForBase64(String key, String imageUrl) {
        CacheUtils.setString(BaseApplication.getContext(), key, imageUrl);
    }

    public static void setPhotoNo(String photoNo) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.PHOTO_NO, photoNo);
    }

    public static String getPhotoNo() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.PHOTO_NO);
    }

    public static void setMemPhotoNo(String photoNo) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.MEM_PHOTO_NO, photoNo);
    }

    public static String getMemPhotoNo() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.MEM_PHOTO_NO);
    }

    public static void setGender(int gender) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.GENDER, gender);
    }

    public static int getGender() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.GENDER);
    }

    /**
     * 店铺是否支持购买
     * 1支持 2不支持
     */
    public static void setShopBuyConfigInfo(int buyConfig) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.SHOP_BUY_CONFIG_INFO, buyConfig);
    }

    public static int getShopBuyConfigInfo() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.SHOP_BUY_CONFIG_INFO);
    }

    /**
     * 是否支持店铺识别男性
     * 1.支持 2.不支持
     */
    public static void setShopMaleSupport(int maleSupport) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.SHOP_MALE_CONFIG_INFO, maleSupport);
    }

    public static int getShopMaleSupport() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.SHOP_MALE_CONFIG_INFO);
    }

    /**
     * 是否支持中秋活动
     */
    public static void setZqSupport(int zqSupport) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.ZQ_SUPPORT, zqSupport);
    }

    public static int getZpSupport() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.ZQ_SUPPORT, -1);
    }


    public static void setClipBitmap(String bitmap) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.CLIP_BITMAP, bitmap);
    }

    public static String getClipBitmap() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.CLIP_BITMAP);
    }

    /**
     * 用户是否是当天第一次进入APP
     *
     * @param flag 0进入过  1未进入
     */
    public static void setTodayHasUse(int flag) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.TODAY_HAS_USE, flag);
    }

    public static int getTodayHasUse() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.TODAY_HAS_USE, 1);
    }


    /**
     * 是否支持春节红包活动
     */
    public static void setRedPacketSupport(int redPacketSupport) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.RED_PACKET_SUPPORT, redPacketSupport);
    }

    public static int getRedPacketSupport() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.RED_PACKET_SUPPORT, -1);
    }

    /**
     * 红包是否达到上限
     */
    public static void setRedPacketNumFlag(int redPacketNumFlag) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.RED_PACKET_NUM_FLAG, redPacketNumFlag);
    }

    public static int getRedPacketNumFlag() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.RED_PACKET_NUM_FLAG);
    }

    /**
     * 是否已经领取过红包
     */
    public static void setReceiveRedPacketFlag(int receiveRedPacketFlag) {
        CacheUtils.setInt(BaseApplication.getContext(), Constants.RED_PACKET_YET_RECEIVE, receiveRedPacketFlag);
    }

    public static int getReceiveRedPacketFlag() {
        return CacheUtils.getInt(BaseApplication.getContext(), Constants.RED_PACKET_YET_RECEIVE, -1);
    }

    /**
     * 二维码
     */
    public static void setRedPacketQrCode(String qrCode) {
        CacheUtils.setString(BaseApplication.getContext(), Constants.RED_PACKET_QR_CODE, qrCode);
    }

    public static String getRedPacketQrCode() {
        return CacheUtils.getString(BaseApplication.getContext(), Constants.RED_PACKET_QR_CODE);
    }

    /**
     * 设置红包金额
     */
    public static void setRedPacketAmount(float redPacketAmount) {
        CacheUtils.setFloat(BaseApplication.getContext(), Constants.RED_PACKET_AMOUNT, redPacketAmount);
    }

    public static float getRedPacketAmount() {
        return CacheUtils.getFloat(BaseApplication.getContext(), Constants.RED_PACKET_AMOUNT, 0.0f);
    }

}
